home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 962 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: What is '?' in C mean....?????
  5. Date: 10 Jan 1996 15:14:42 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan10101442@g7240065.bridge.bst.bls.com>
  8. References: <4cgsa8$bm2@wumpus.cc.uow.edu.au> <4cvp4d$b6u@news.worldlinx.com>
  9. NNTP-Posting-Host: bstfirewall.bst.bls.com
  10. In-reply-to: stupy@freenet.durham.org's message of 10 Jan 1996 07:16:29 GMT
  11.  
  12. In article <4cvp4d$b6u@news.worldlinx.com> stupy@freenet.durham.org (Steve Tupy) writes:
  13. : PAOPENG THEERADECH (tp86@wumpus.cc.uow.edu.au) wrote:
  14.  
  15. :: Hello to all.
  16. ::     I got something here to ask you guys. I saw some symbol like "?" be
  17. :: used in some codes. I don't understand what does it mean. I tried to read some
  18. :: text books but I still cannot find the detail about "?". The codes that I saw 
  19. :: are;
  20. ::         max = x>y ? x:y;
  21. ::          
  22. ::             and
  23.  
  24. ::         printf("%d", x>y ? x:y);
  25.  
  26. : It tells you that an evaluation is about to happen. If x>y then max = x, if
  27. : x>y == 0 then max = y. The first value left of the colon is applied only if
  28. : it evaluates to 1, else the right side is applied.
  29.  
  30. That should really be: The first value left of the colon is applied
  31. if the expression doesn't evaluate to 0, else the right side is applied.
  32. Any non-zero value will cause the left hand side to be evaluated, in C
  33. anything non-zero is true ;')
  34.  
  35. Regards
  36.  
  37.     -A.
  38. -- 
  39. | A.Champion                |
  40.